<!-- 待发任务详情 -->
<template>
	<view>
		<web-view :update-title="false"	:fullscreen="false" :src="fileUrl"></web-view>
		<view class="px-3" :style="btnStyle">
			<bg-btn style="background-color: #ffefe7;color:#EE3636;">
				共计待发金额：{{totalAmount}}元
			</bg-btn>
		</view>
		<view class="bt-footer" v-if="show">
			<bg-btn @click="saveData()">
				立即发放
			</bg-btn>
		</view>
	</view>
</template>

<script>
	import { immediatelySend, exportAlready,toSendDetail } from '../../../api/apply'
	export default {
		data() {
			return {
				projectId:'',
				totalAmount:'',
				fileUrl:'',
				show:false,
				btnStyle:{
					position: 'fixed',
					width: '100%',
					bottom: '10px'
				},
				wv:null,
			}
		},
		onLoad(options) {
			this.projectId = options.pid
			this.totalAmount = options.total
			this.show = options.show
			this.type = options.type
			if(this.show){
				uni.setNavigationBarTitle({
					title:"待发任务详情"
				})
				this.btnStyle.bottom = "90px"
			}else {
				uni.setNavigationBarTitle({
					title:"已发任务详情"
				})
			}
			this.getData()
		},
		methods: {
			getData(){
				if(this.type=='df'){
					toSendDetail({projectId:Number(this.projectId)}).then(res=>{
					this.fileUrl = res.data.excelUrl
					this.totalAmount = res.data.sumAmount
					// #ifdef APP-PLUS
						var currentWebview = this.$mp.page.$getAppWebview(); //获取当前web-view
						var wv = currentWebview.children()[0];
						this.wv = wv
						uni.getSystemInfo({
							success:({windowHeight})=>{
								setTimeout(()=>{
									if(this.show){
										wv.setStyle({height:windowHeight-150})
									} else {
										wv.setStyle({height:windowHeight-70})
									}
								}, 1000);
							}
						})
						
					// #endif
				})
				}else{
					exportAlready({projectId:Number(this.projectId)}).then(res=>{
					this.fileUrl = res.data.excelUrl
					this.totalAmount = res.data.sumAmount
					// #ifdef APP-PLUS
						var currentWebview = this.$mp.page.$getAppWebview(); //获取当前web-view
						var wv = currentWebview.children()[0];
						this.wv = wv
						uni.getSystemInfo({
							success:({windowHeight})=>{
								setTimeout(()=>{
									if(this.show){
										wv.setStyle({height:windowHeight-150})
									} else {
										wv.setStyle({height:windowHeight-70})
									}
								}, 1000);
							}
						})
						
					// #endif
				})
				}
				
			},
			saveData(){
				immediatelySend({projectId:this.projectId}).then(res=>{
					uni.$emit("refresh-grant", true)
					this.$modal.msg("提交成功")
					this.$tab.navigateBackDelay()
				})
			}
		}
	}
</script>

<style>

</style>
